import java.util.Scanner;

public class TheFirstQuestion {
    // DP34 【模板】前缀和 https://www.nowcoder.com/practice/acead2f4c28c401889915da98ecdc6bf?tpId=230&tqId=2021480&ru=/exam/oj&qru=/ta/dynamic-programming/question-ranking&sourceUrl=%2Fexam%2Foj%3Fpage%3D1%26tab%3D%25E7%25AE%2597%25E6%25B3%2595%25E7%25AF%2587%26topicId%3D196
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别

        int a = in.nextInt();// a 个数
        int b = in.nextInt();// b 次查询
        // 接收a个数组元素
        long[] dp=new long[a+1];// 防止溢出
        dp[0]=0;
        for(int i=1;i<=a;i++) {
            dp[i]=dp[i-1]+in.nextInt();
        }
        // 进行b次查询
        while(b!=0) {
            int l=in.nextInt();
            int r=in.nextInt();
            System.out.println( dp[r]-dp[l-1] );
            b--;
        }
    }
}
